<?php if (!defined('insite')) die("no access"); ?>
<table width="50%" border="0" align="center" cellpadding="0" cellspacing="4" class='tableMain'>
<tr><td colspan="2" class='trheader'><?=contact_title?></td></tr>

<?php 
if (isset($_GET["del"]))
{
	$num =(int)$_GET["del"];
	$contacts = @file("_dat/contact.dat");
	$c_handle = @fopen("_dat/contact.dat","w");
	for ($i=0;$i<count($contacts);$i++)	
	{
		if($i!=$num) fwrite ($c_handle,$contacts[$i]);	
	}
	fclose ($c_handle);

}?>
<form method="POST" name="couta_us" action="<?=$config["siteaddress"]?>/index.php?p=usercp&ss=contacts">
<tr>
<td><?=contact_chs?></td>
<td>
	<select name="c-type" class="combx">
	<option value="icq">ICQ</option>
	<option value="skype">Skype</option>
	<option value="gmail">Mail</option>
	</select>
</td>
</tr>
<tr>
<td><?=contact_tex?></td>
<td> <input type="text" maxlength="20" name="c_text" class='texbx'> </td>
</tr>
<tr><td colspan="2" align="center"><input type="submit" value="Add" class="t-button" name="add_c"></td></tr>
</form>
<?
if ($_REQUEST["add_c"])
{
?><tr><td colspan="2"><?
 $type= substr($_POST["c-type"],0,5);
 if ($type == "gmail") $contact = checkwordm(substr($_POST["c_text"],0,20));
 else $contact = validate(substr($_POST["c_text"],0,20));
 if(strlen($contact)>2)
  {
	$c_handle = fopen("_dat/contact.dat","a");
	fwrite ($c_handle,$type."::".$contact."\r\n");
	fclose ($c_handle);
	
  }else echo "<span class='warnms'> Write error!</span>";
 ?></td></tr><? 
}?>
<tr><td colspan="2"><table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
<?
 require "opt.php";
 $contacts = @file("_dat/contact.dat");
 if ($contacts)
 {
  $i=0;
  foreach ($contacts as $temp)
  {
	list($typeZ,$contactZ) = split("::",$temp);
	if ($typeZ!="gmail"){?><tr><td><img src="imgs/<?=$typeZ?>.png" alt="<?$typeZ?>"></td><td><?=$contactZ?></td><td align="right"><a href="<?=$config["siteaddress"]?>/index.php?p=usercp&ss=contacts&del=<?=$i?>"><img src='imgs/delete.png' title='delete' border='0'></a></td></tr><?}
	else{?><tr><td><img src="imgs/<?=$typeZ?>.png" alt="<?$typeZ?>"></td><td><a href="mailto:<?=$contactZ?>"><?=$contactZ?></a></td><td align="right"><a href="<?=$config["siteaddress"]?>/index.php?p=usercp&ss=contacts&del=<?=$i?>"><img src='imgs/delete.png' title='delete' border='0'></a></td></tr><?}
	$i++;
  }
 }
 ?></table></td></tr>
</table>
